﻿using System.ComponentModel.Composition;
using System.Windows.Controls;
using Microsoft.OpenTurf.Silverlight.Common;
using Microsoft.OpenTurf.Silverlight.ViewModel;
using Microsoft.Maps.MapControl;

namespace Microsoft.OpenTurf.Silverlight
{
    [Export(typeof(IMapView))]
    public partial class MapView : UserControl, IMapView
    {
        [ImportingConstructor()]
        public MapView()
        {
            InitializeComponent();
            Loaded += new System.Windows.RoutedEventHandler(MapView_Loaded);
        }

        void MapView_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            MapView view = sender as MapView;
            if (view == null) return;

            MapViewModel viewModel = view.DataContext as MapViewModel;
            viewModel.MapControl = Map;
        }
    }
}
